package com.ruoyi.student.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.student.domain.vo.TClassVo;
import com.ruoyi.student.domain.vo.TCourseInfoVo;
import com.ruoyi.student.mapper.ReCourseClassMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.student.mapper.TClassMapper;
import com.ruoyi.student.domain.TClass;
import com.ruoyi.student.service.ITClassService;

/**
 * 班级Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-08-15
 */
@Service
public class TClassServiceImpl implements ITClassService 
{
    @Autowired
    private TClassMapper tClassMapper;
    @Autowired
    private ReCourseClassMapper reCourseClassMapper;

    /**
     * 查询班级
     * 
     * @param id 班级主键
     * @return 班级
     */
    @Override
    public TClass selectTClassById(Long id)
    {
        return tClassMapper.selectTClassById(id);
    }
    public TClassVo selectTClassVoById(Long id)
    {
        TClassVo tClassVo = tClassMapper.selectTClassVoById(id);
        List<TCourseInfoVo> tCourseInfoVos = reCourseClassMapper.selectCourseListByClassId(id);
        tClassVo.setTCourseInfoVos(tCourseInfoVos);
        return tClassVo;
    }

    /**
     * 查询班级列表
     * 
     * @param tClass 班级
     * @return 班级
     */
    @Override
    public List<TClass> selectTClassList(TClass tClass)
    {
        return tClassMapper.selectTClassList(tClass);
    }

    /**
     * 查询班级列表
     *
     * @param tClass 班级
     * @return 班级
     */
    @Override
    public List<TClassVo> selectTClassVoList(TClass tClass)
    {
        return tClassMapper.selectTClassVoList(tClass);
    }


    /**
     * 新增班级
     * 
     * @param tClass 班级
     * @return 结果
     */
    @Override
    public int insertTClass(TClass tClass)
    {
        tClass.setCreateTime(DateUtils.getNowDate());
        return tClassMapper.insertTClass(tClass);
    }

    /**
     * 修改班级
     * 
     * @param tClass 班级
     * @return 结果
     */
    @Override
    public int updateTClass(TClass tClass)
    {
        tClass.setUpdateTime(DateUtils.getNowDate());
        return tClassMapper.updateTClass(tClass);
    }

    /**
     * 批量删除班级
     * 
     * @param ids 需要删除的班级主键
     * @return 结果
     */
    @Override
    public int deleteTClassByIds(Long[] ids)
    {
        return tClassMapper.deleteTClassByIds(ids);
    }

    /**
     * 删除班级信息
     * 
     * @param id 班级主键
     * @return 结果
     */
    @Override
    public int deleteTClassById(Long id)
    {
        return tClassMapper.deleteTClassById(id);
    }
}
